from PIL import Image
import numpy as np
from lib.rgb2cmyk import convert2cmyk

image = Image.open("./resources/img/avatar.png")
image_rgb = image.convert("RGB")
# image_cmyk = image.convert("CMYK")

rgb_array = np.array(image_rgb)
# cmyk_array = np.array(image_cmyk)

print("rgb_array: ")
print(rgb_array)

cmyk_array = np.array(convert2cmyk(rgb_array))
image_cmyk = Image.fromarray(cmyk_array, mode="CMYK")
image_cmyk.save("./out/output_cmyk.tiff", "TIFF")

# with open("./out/rgb_array.txt", "w") as file:
# 	for row in rgb_array:
# 		for pixsel in row:
# 			np.savetxt(file, [pixsel], fmt="%d")

print("cmyk_array: ")
print(cmyk_array)

# with open("./out/cmyk_array.txt", "w") as file:
# 	for row in cmyk_array:
# 		for pixsel in row:
# 			np.savetxt(file, [pixsel], fmt="%d")
